package com.ruoyi.qywx.callback.events;

import com.ruoyi.common.core.cache.Meta;
import com.ruoyi.qywx.callback.txl.ExternalTagEncrypt;
import com.ruoyi.qywx.enums.QyNotificationType;
import com.ruoyi.qywx.service.inters.SyncQiyeService;

/**
 * @author : hcl
 * @Date : 2023/8/25 09:28
 */
public class ExternalTagEvent extends QywxEvent<ExternalTagEncrypt> {
    public ExternalTagEvent(SyncQiyeService syncService, ExternalTagEncrypt encrypt, Meta meta) {
        super(syncService, encrypt, meta);
    }

    @Override
    public void eventExecute() {
        ExternalTagEncrypt encrypt = getEncrypt();
        // 企业客户标签重排事件 排除 不响应
        if (encrypt.getChangeType().equals("shuffle")) return;
        QyNotificationType type = QyNotificationType.valueOf(
                (encrypt.getChangeType() + "_" + encrypt.getTagType()).toUpperCase()
        );
        getSyncService().notificationCreateTag(encrypt, getMeta(), type);
    }
}
